<!-- 会员中心主内容区 -->
<div class="page-article">
  <div id="member_security" class="member-security">
    <div class="member-title">
      <h2><{if $verifyType == 'setpaypassword'}><{t}>预存款支付密码<{/t}><{elseif $verifyType == 'setmobile' || $verifyType == 'verifymobile'}><{t}>手机验证<{/t}><{else}><{t}>邮箱验证<{/t}><{/if}></h2>
    </div>
    <!-- 步骤图 -->
    <div id="verify_steps" class="steps steps-three">
      <table width="100%">
        <tbody>
          <tr>
            <td class="step-item step-1 active"><span><q class="icon">&#x50;</q><i>1</i><{t}>身份验证<{/t}></span></td>
            <td class="icon step-arrow active">&#x28;</td>
            <td class="step-item step-2 active" ><span><q class="icon">&#x50;</q><i>2</i><{t}>设置验证信息<{/t}></span></td>
            <td class="icon step-arrow">&#x28;</td>
            <td class="step-item step-3"><span><q class="icon">&#x50;</q><i>3</i><{t}>完成<{/t}></span></td>
          </tr>
        </tbody>
      </table>
    </div>

    <div id="verify_content" class="signupin-content verify-content">
      <form action="<{link app=b2c ctl=site_member act=verify_vcode2 arg0=$verifyType}>" method="post">
        <ul>
          <{if $verifyType == 'setpaypassword' || $verifyType == 'verifypaypassword'}>
          <li class="form-item">
            <label for="" class="form-label">输入您的支付密码：</label>
            <span class="form-act"><{input type="password" name="pay_password" id="" vtype="required" placeholder="6~20个字符" maxlength="20"}></span>
            <span class="caution-content"><{$msg}></span>
          </li>
          <li class="form-item">
            <label for="" class="form-label">确认您的支付密码：</label>
            <span class="form-act"><{input type="password" name="re_pay_password" id="" vtype="required" placeholder="重复输入以上密码" maxlength="20"}></span>
            <span class="caution-content"><{$msg}></span>
          </li>
          <li class="form-item"><span class="form-act"><{button type="submit" rel="_request" class="btn-caution btn-big" label="提交"}></span></li>
          <{else}>
          <{if $verifyType == 'setmobile' || $verifyType == 'verifymobile'}>
          <{if $site_sms_valide == 'true'}>
          <li class="form-item">
            <label for="" class="form-label"><em class="warn">*</em>验证码：</label>
            <span class="form-act">
              <{input type="vcode" name="forgotverifycode" class="sms-verify-input" placeholder="填写验证码" data-caution="请正确填写验证码" key='LOGINVCODE' a_class="lnklike"}>
            </span>
          </li>
          <{/if}>
          <li class="form-item">
            <label for="" class="form-label">手机号码：</label>
            <span class="form-act">
              <{if $verifyType == 'setmobile'}>
              <input type="hidden" name='send_type'  value="reset">
              <{input type="text" name="uname" id="" class="action-account-check" vtype="required&&mobile"}> <a href="<{link app=b2c ctl=site_passport act=send_vcode_sms}>" class="btn btn-caution action-get-verifycode">
                <span><span><{t}>获取验证码<{/t}></span></span></a>
              <{/if}>
              <{if $verifyType == 'verifymobile'}>
                <{if $data.mobile}>
                  <{$data.mobile}>
                  <input type="hidden" name='send_type' value="activation">
                  <input type="hidden" name='uname' class="action-account-check" value=<{$data.mobile}> >
                <{else}>
                  <input type="hidden" name='send_type'  value="reset">
                  <{input type="text" name="uname" id="" class="action-account-check" vtype="required&&mobile"}>
                <{/if}>
                <a href="<{link app=b2c ctl=site_passport act=send_vcode_sms}>" class="btn btn-caution action-get-verifycode"><span><span>获取验证码</span></span></a>
              <{/if}>
            </span>
          </li>
          <{else}>
          <li class="form-item">
            <label for="" class="form-label">邮箱：</label>
            <span class="form-act">
              <{if $verifyType == 'setemail'}>
              <input type="hidden" name='send_type'  value="reset">
              <{input type="text" name="uname" id="" class="action-account-check" vtype="required&&email"}>
              <a href="<{link app=b2c ctl=site_passport act=send_vcode_email}>" class="btn btn-caution action-resend-email"><span><span>发送邮箱验证码</span></span></a>
              <{/if}>
              <{if $verifyType == 'verifyemail'}>
                <{if $data.email}>
                  <input type="hidden" name='send_type'  value="reset">
                  <{input type="text" name="uname" id="" class="action-account-check" value=$data.email vtype="required&&email"}>
                <{else}>
                  <input type="hidden" name='send_type'  value="reset">
                  <{input type="text" name="uname" id="" class="action-account-check" vtype="required&&email"}>
                <{/if}>
                <a href="<{link app=b2c ctl=site_passport act=send_vcode_email}>" class="btn btn-caution action-resend-email"><span><span>发送邮箱验证码</span></span></a>
              <{/if}>
              </span>
          </li>
          <{/if}>
          <li class="form-item">
            <label for="" class="form-label">填写验证码：</label>
            <span class="form-act"><{input type="text" name="vcode" id="" vtype="required"}></span>
            <span class="caution-content"><{$msg}></span>
          </li>
          <li class="form-item"><span class="form-act"><{button type="submit" rel="_request" class="btn-caution btn-big" label="提交"}></span></li>
          <{/if}>
        </ul>
      </form>
      <!--
      <div class="msg"><i class="icon icon-success">&#x25;</i> 恭喜您，您的手机已经验证完成，将会获取更好的安全体验</div>
      -->
    </div>
  </div>
</div>
<script>
var module = $('verify_content');
var Query = {
    send: function(url, data, fn){
        new Request({
            url: url,
            link: 'cancel',
            onSuccess: function(rs) {
                try{
                    rs = JSON.decode(rs);
                }catch(e){}
                if(typeof rs.error === 'string') Message.error(rs.error);
                else if(typeof rs.success === 'string') Message.success(rs.success);
                fn && fn.call(this, rs);
            }
        }).post(data);
    }
};

function changeStep(rs, x, fn) {
    if(rs && rs[0]) {
        if(typeOf(rs[0]) === 'string') {
            module.innerHTML = rs[0];
            if(x) $('verify_steps').getElement('.active').removeClass('active').getSiblings('.step-' + x).addClass('active');
        }
        else if(typeOf(rs[0]) === 'object') {
            if(rs[0].error) return Message.error(rs[0].error);
        }
        fn && fn.call(this);
    }
}
module.addEvents({
    'change:relay(.action-verify-method)': function(e) {
        var form = this.getParent('form');
        form.getElements('.op-verify-mobile, .op-verify-email').addClass('hide');
        form.getElements('.op-verify-' + this.value).removeClass('hide');
    },
    'click:relay(.action-resend-email)':function(e) {
        e.stop();
        var url = this.href;
        var data = 'uname=' + module.getElement('.action-account-check').value + '&type=' + module.getElement('input[name=send_type]').value;
        Query.send(url, data);
    },
    'click:relay(.action-get-verifycode)': function(e) {
        e.stop();
        if(this.hasClass('disabled')) return false;
        var el = module.getElement('.action-account-check');
        if(this.hasClass('disabled')) return false;
        <{if $site_sms_valide == 'true'}>
        var form = this.getParent('form');
        if(form.getElement('.sms-verify-input').value == '')
        {
          alert('请输入验证码!');return;
        }
        sendVerify(this, 'uname=' + el.value + '&type=' + module.getElement('input[name=send_type]').value + '&sms_vcode=' + form.getElement('.sms-verify-input').value );
        <{else}>
        sendVerify(this, 'uname=' + el.value + '&type=' + module.getElement('input[name=send_type]').value);
        <{/if}>
    }
});

function sendVerify(el, data) {
    var url = el.href;
    el.addClass('disabled');
    var textCont = el.getElement('span span');
    textCont.innerHTML = el.get('text') + '(<i>0</i>)';
    var cd = new countdown(textCont.getElement('i'), {
        start: 120,
        secondOnly: true,
        callback: function(e) {
            el.removeClass('disabled');
            textCont.innerHTML = '重发验证码';
        }
    });
    Query.send(url, data, function(rs){
        if(rs.error) {
          cd.stop();
          el.removeClass('disabled');
          textCont.innerHTML = '重发验证码';
        }
    });
}
</script>
